package com.xs.readword;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class RegisterActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        Button button6 = findViewById(R.id.button6);
        Button button7 = findViewById(R.id.button7);
        button6.setOnClickListener(this);
        button7.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button6:
                finish();
                break;
            case R.id.button7:
//                Intent intent2 =new Intent(RegisterActivity.this,MainActivity.class);
//                Toast.makeText(this, "注冊成功，請登錄", Toast.LENGTH_SHORT).show();
//                startActivity(intent2);
                goLogin();
                break;
        }
    }

    //注册方法
    private void goLogin() {
        //弹出注册成功对话框
        AlertDialog.Builder builder = new AlertDialog.Builder(RegisterActivity.this);
        builder.setTitle("注册成功");
        builder.setMessage("是否登录？");
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent intent = new Intent(RegisterActivity.this,WordOperateActivity.class);
                startActivity(intent);
            }
        });
        builder.setNegativeButton("取消",null);
        builder.show();
    }

}